package cn.lzy.config;

import cn.lzy.config.entity.Dog;
import cn.lzy.config.entity.User;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @Description
 * @Author lzy
 * @Date 2023/11/23 23:28
 * @Version
 **/
public class TestDemo {


    public static void main(String[] args) {
        // AnnotationConfigApplicationContext：加载Java代码（即java文件）配置的容器
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(JavaConfig.class);
        User u1 = ctx.getBean("u1", User.class);
        User u2 = ctx.getBean("u2", User.class);
        Dog dog = ctx.getBean("dog", Dog.class);
        System.out.println("u1 = " + u1);
        System.out.println("u2 = " + u2);
        System.out.println("========================");
        System.out.println("(u1.getDog() == dog) = " + (u1.getDog() == dog));
        System.out.println("(u2.getDog() == dog) = " + (u2.getDog() == dog));

    }
}
